package com.xb.system.controller;

import com.xb.system.service.DynamicDataSplitterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "1、入库") //Swagger生成api的提示
@RestController
@RequestMapping("/admin/system/sysFile")
public class FileUploadController {

    @Resource
    private DynamicDataSplitterService dynamicDataSplitterService;

    @PostMapping("/upload")
    @ApiOperation(value = "输入文件路径，解析入库")
    public String uploadFile(String filePath) {
        try {
            dynamicDataSplitterService.splitData(filePath);
            return "文件已上传并处理成功!";
        } catch (Exception e) {
            return "无法处理文件:" + e.getMessage();
        }
    }
}